﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using OpenMms.Common.Auth;
using OpenMms.Common.Session;
using Microsoft.AspNetCore.Mvc;

namespace OpenMms.MVC.Controllers
{
    /// <summary>
    /// Session信息获取
    /// </summary>
    public class UserSessionController : Controller
    {
        #region 初始化
        public const string Token = "Token";

        private IAuth _authUtil;

        public UserSessionController(IAuth authUtil)
        {
            this._authUtil = authUtil;
        }
        #endregion

        #region 获取登录信息
        /// <summary>
        /// 获取登录用户信息
        /// </summary>
        /// <returns></returns>
        public JsonResult GetSession()
        {
            return Json(_authUtil.GetCurrentUser());
        }
        #endregion

        #region 退出登录
        /// <summary>
        /// 退出登录
        /// </summary>
        public void Logout()
        {
            _authUtil.Logout();
        }
        #endregion

    }
}